<include file="Public/min-header"/>
<div class="wrapper">
    <include file="Public/breadcrumb"/>
<!--以下是在线编辑器 代码 -->
<style type="text/css">
	.form-control{height:auto;}
	.text-warning input{border:none; width:350px;}
</style>
<?php $myurl="https://".$_SERVER['SERVER_NAME'];?>
<script type="text/javascript">
    /*
	 * 在线编辑器相 关配置 js 
	 *  参考 地址 http://fex.baidu.com/ueditor/ 
	 */
    window.UEDITOR_Admin_URL = "__ROOT__/Public/plugins/Ueditor/";
    var URL_upload = "{$myurl}{$URL_upload}";
    var URL_fileUp = "{$myurl}{$URL_fileUp}";
    var URL_scrawlUp = "{$myurl}{$URL_scrawlUp}";
    var URL_getRemoteImage = "{$myurl}{$URL_getRemoteImage}";
    var URL_imageManager = "{$myurl}{$URL_imageManager}";
    var URL_imageUp = "{$myurl}{$URL_imageUp}";
    var URL_getMovie = "{$myurl}{$URL_getMovie}";
    var URL_home = "{$myurl}{$URL_home}";
	var URL_Config = "{$myurl}/Admin/Ueditor/getConfig";
</script>
<script type="text/javascript" charset="utf-8" src="__ROOT__/Public/plugins/Ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__ROOT__/Public/plugins/Ueditor/ueditor.all.js"> </script>
 <script type="text/javascript" charset="utf-8" src="__ROOT__/Public/plugins/Ueditor/lang/zh-cn/zh-cn.js"></script>
 <link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
 <script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
 <script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<script type="text/javascript">  
  
//     var editor;
//     $(function () {
//         //具体参数配置在  editor_config.js  中
//         var options = {
//             zIndex: 999,
//             initialFrameWidth: 750, //初化宽度
//             initialFrameHeight: 400, //初化高度
//             focus: false, //初始化时，是否让编辑器获得焦点true或false
//             maximumWords: 99999, removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign'
//             , //允许的最大字符数 'fullscreen',
//             pasteplain:false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
//             autoHeightEnabled: true
// 			,
//         	toolbars: [
//                   ['fullscreen', 'source', '|', 'undo', 'redo',
//                       '|', 'bold', 'italic', 'underline', 'fontborder',
//                       'strikethrough', 'superscript', 'subscript',
//                       'removeformat', 'formatmatch', 'autotypeset',
//                       'blockquote', 'pasteplain', '|', 'forecolor',
//                       'backcolor', 'insertorderedlist',
//                       'insertunorderedlist', 'selectall', 'cleardoc', '|',
//                       'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
//                       'customstyle', 'paragraph', 'fontfamily', 'fontsize',
//                       '|', 'directionalityltr', 'directionalityrtl',
//                       'indent', '|', 'justifyleft', 'justifycenter',
//                       'justifyright', 'justifyjustify', '|', 'touppercase',
//                       'tolowercase', '|', 'link', 'unlink', 'anchor', '|',
//                       'imagenone', 'imageleft', 'imageright', 'imagecenter',
//                       '|', 'insertimage', 'emotion', 'insertvideo',
//                       'attachment', 'map', 'gmap', 'insertframe',
//                       'insertcode', 'webapp', 'pagebreak', 'template',
//                       'background', '|', 'horizontal', 'date', 'time',
//                       'spechars', 'wordimage', '|',
//                       'inserttable', 'deletetable',
//                       'insertparagraphbeforetable', 'insertrow', 'deleterow',
//                       'insertcol', 'deletecol', 'mergecells', 'mergeright',
//                       'mergedown', 'splittocells', 'splittorows',
//                       'splittocols', '|', 'print', 'preview', 'searchreplace']
//               ]
//         };
//         editor = new UE.ui.Editor(options);
//         editor.render("smtp_content");
//         try {
//             //添加自定义类名content,用于设置编辑器里的样式  
//             editor.addListener('ready', function (editor) {
// 			var aa=$('#ueditor_0').contents().find('body').attr('id','shadow');
//             });
//         } catch (err) {}
            
//     }); 

    var ue = UE.getEditor('content', {
        // ... 更多配置
        serverUrl:URL_Config,
		allowDivTransToP:false,
		initialFrameHeight:500
    }); 
</script>
    <section class="content">
        <!-- Main content -->
        <div class="container-fluid">
            <div class="pull-right">
                <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
            </div>
            <div class="panel panel-default">           
                <div class="panel-body ">   
                   	<ul class="nav nav-tabs">
                        <foreach name="group_list" item="vo" key="k">
                     		<li <if condition="$k eq 'smtp'">class="active"</if>><a href="javascript:void(0)" data-url="{:U('System/index',array('inc_type'=>$k))}" data-toggle="tab" onclick="goset(this)">{$vo}</a></li>
                     	</foreach>                        
                    </ul>
                    <!--表单数据-->
                    <form method="post" id="handlepost" action="{:U('System/addEditTemplate')}">
                        <!--通用信息-->
                    <div class="tab-content" style="padding:20px 0px;">                 	  
                        <div class="tab-pane active" id="tab_smtp">                           
                            <table class="table table-bordered">
                                <tbody>
									<tr>
										<td colspan="2">
											<p class="text-warning">
											店铺链接：<input value="/pages/store/index?store_id="/>
											&nbsp;&nbsp;产品链接：<input value="/pages/goods_details/goods_details?id=" style="width: 300px;"/><br/>
											店铺专区：<input value="/pages/bundle/zone_page/zone_page?types=1"/>
											&nbsp;&nbsp;产品专区：<input value="/pages/bundle/zone_page/zone_page?types=2"/><br/>
											店铺活动专栏：<input value="/pages/bundle/hot_list/hot_list?store_id="/>
											排行榜：<input value="/pages/webview/webview?url=https://yc.zczmer.com/mobile/index/usertop"/><br/>
											转盘活动：<input value="/pages/webview/webview?url=https://yc.zczmer.com/mobile/index/zhuanpan"/>

<!--											排版样式：<input value='class="top" class="lo"'/>-->
											</p>
										</td>
									</tr>
								<tr>
									<td class="col-sm-2">标题：</td>
									<td class="col-sm-8">
										<input type="text" class="form-control" name="title" value="{$template.title}" style="width: 120px;">
										<span id="err_title" style="color:#F00; display:none;"></span>
									</td>
								</tr>
								<tr>
									<td>启用活动版面：</td>
									<td> 
										<input id="turnOn" type="radio" class="" name="is_show" <if condition="$template['is_show'] eq 1">checked</if> value="1" >是 &nbsp; 
										<input type="radio"  class="" name="is_show" <if condition="$template['is_show'] eq 0">checked</if> value="0" >否
									</td>
								</tr>
								<tr>
									<td>活动模板类型：</td>
									<td>
										<input id="turnOn" type="radio" class="" name="type" <if condition="$template['type'] eq 1">checked</if> value="1" >首页活动模板 &nbsp; 
										<input type="radio"  class="" name="type" <if condition="$template['type'] eq 2">checked</if> value="2" >店铺专区
										<input type="radio"  class="" name="type" <if condition="$template['type'] eq 3">checked</if> value="3" >产品专区
									</td>
								</tr>
								<tr>
									<td>活动版面有效时间：</td>
									<td> 
										<input type="text" name="timegap" value="{$timegap}" placeholder=""  id="add_time" class="input-sm" style="width: 220px;">
									</td>
								</tr>
								<tr>
									<td class="col-sm-2">广告图高度：</td>
									<td class="col-sm-8">
										<input type="text" class="form-control" id="bg_height" name="bg_height" value="{$template.bg_height}" style="width: 120px;">
										<span id="err_bg_height" style="color:#F00; display:none;"></span>
									</td>
								</tr>
								<tr>
								    <td class="col-sm-2">底纹颜色：</td>
								    <td class="col-sm-8">
								    <input type="text" class="form-control" name="smtp_bg" value="{$template.smtp_bg}" style="width: 120px;">
								    <span id="err_attr_name" style="color:#F00; display:none;"></span> 
								    </td>
								</tr>
								<tr>
								    <td class="col-sm-2">分部选择：</td>
								    <td class="col-sm-8">

										<volist name='fenbu_list' id='vo'>
											<div style="width:150px;height:50px;display:block;margin-right: 10px;float: left;text-align: center;line-height: 50px">
												{$vo.fenbu_name}<input name="fenbu_id[]" <if condition="$vo.status eq 1"> checked="checked"</if>  type="checkbox" value="{$vo.fenbu_id}">
											</div>
										</volist>
								    </td>
								</tr>
                                <tr>
                                    <td class="col-sm-2">活动版面设计：</td>
                                    <td class="col-sm-8">
                         				<textarea class="form-control" id="content" name="content">{$template.content}</textarea>
                         				<p class="text-warning">先在ps切图，导出html再复制到此编辑器进行连接编辑。</p>
                                    </td>
                                </tr>
                                </tbody> 
                                <tfoot>
                                	<tr>
									<input type="hidden" name="id" value="{$template.id}">
                                	<td class="text-right"><input class="btn btn-primary" type="button" onclick="adsubmit()" value="保存"></td></tr>
                                </tfoot>                               
                                </table>
                        </div>                           
                    </div>              
			    	</form><!--表单数据-->
                </div>
            </div>
        </div>
    </section>
</div>

<script>
var flag = true;
function adsubmit(){
    var bg_height = $('#bg_height').val()
    if(bg_height <= 0 ){
        layer.msg('请填写高度', {icon: 2,time: 2000});
        return false;
    }
    
	check_form();
	if(flag){
		$('#handlepost').submit();
	}
}
$('#add_time').daterangepicker({
			format:"YYYY-MM-DD HH:mm",
			singleDatePicker: false,
			showDropdowns: true,
			minDate:'2021-01-01 00:00',
			maxDate:'2030-01-01 00:00',
			startDate:'{:date("Y-m-d")} 00:00',
	        showWeekNumbers: true,
	        timePicker: true,
	        timePickerIncrement: 1,
	        timePicker12Hour: false,
	        opens: 'right',
	        buttonClasses: ['btn btn-default'],
	        applyClass: 'btn-small btn-primary',
	        cancelClass: 'btn-small',
		    locale : {
	            applyLabel : '确定',
	            cancelLabel : '取消',
	            fromLabel : '起始时间',
	            toLabel : '结束时间',
	            customRangeLabel : '自定义',
	            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
	            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
	            firstDay : 1
	        }
		});
function check_form(){
	// if($('input[name="smtp_server"]').val() == ''){
	// 	alert('请填写邮件发送服务器地址');
	// 	flag = false;
	// 	return;
	// }
	// if($('input[name="smtp_user"]').val() == '' || !checkEmail($('input[name="smtp_user"]').val())){
	// 	alert('请填写正确的邮箱账号');
	// 	flag = false;
	// 	return;
	// }
	// if($('input[name="smtp_pwd"]').val() == ''){
	// 	alert('请填写发送邮箱密码');
	// 	flag = false;
	// 	return;
	// }
}

$(document).ready(function(){
	get_province();
});

function goset(obj){
	window.location.href = $(obj).attr('data-url');
}

function sendEmail(){
	if($('input[name="test_eamil"]').val() == '' || !checkEmail($('input[name="test_eamil"]').val())){
		alert('请填写正确的测试邮箱账号');
		return;
	}else{
		$.ajax({
			type : "post",
			data : $('#handlepost').serialize(),
			dataType : 'json',
			url : "{:U('System/send_email')}",
			success : function(res){
				if(res==1){
					layer.msg('发送成功', {icon: 1});
				}else{
					layer.msg('发送失败', {icon: 2,time: 2000});
				}
			}
		})
	}
}
</script>
</body>
</html> 